#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
char s[1000005];
int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    int n,m,T,x;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n+m;++i){scanf("%d",&T);}
    for (x=1;(1<<x)<n;++x){}
    for (int i=1;i<=x;++i){
        scanf("%s",s+1);
    }
    scanf("%d",&T);++T;while (--T){puts("1");}
    return 0;
}
